package cn.iocoder.yudao.module.resource.dal.mysql.audio;

import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.resource.dal.dataobject.audio.LmAudioDO;
import cn.iocoder.yudao.module.resource.dal.mysql.audio.model.LmAudioPageReq;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 音频 Mapper
 *
 * @author wgs
 */
@Mapper
public interface LmAudioMapper extends BaseMapperX<LmAudioDO> {

    default PageResult<LmAudioDO> selectPage(LmAudioPageReq reqVO) {

        return selectPage(reqVO, new LambdaQueryWrapperX<LmAudioDO>()
                .eq(reqVO.getAudioToneId() > 0, LmAudioDO::getAudioToneId, reqVO.getAudioToneId())
                .like(StringUtils.isNotEmpty(reqVO.getName()), LmAudioDO::getTextDesc, reqVO.getName())
                .in(CollectionUtil.isNotEmpty(reqVO.getAudioIdList()), LmAudioDO::getId, reqVO.getAudioIdList())
                .orderByDesc(LmAudioDO::getId));
    }

    default void setDeletedAudio(List<Integer> audioIds) {
        this.deleteBatchIds(audioIds);
    }


}